﻿using QFramework;
using UnityEngine;

namespace Gp.Scripts.Core
{
    public abstract class BaseGameSystem : ISystem, IStructure
    {
        public virtual void OnStart() { }

        public IArchitecture GetArchitecture()
        {
            return MainArchitecture.Interface;
        }

        public void SetArchitecture(IArchitecture architecture) { }

        public void Init()
        {
            Debug.Log("#System Loaded: " + GetType().Name);
            OnInit();
        }

        protected virtual void OnInit() { }


        public void RegisterData<T>(T model) where T : BaseSystemData
        {
            MainArchitecture.Interface.RegisterData(model);
        }
    }


    // /// <summary>
    // /// 系统类
    // /// </summary>
    // /// <typeparam name="T"></typeparam>
    // public abstract class BaseGameSystem<T> : BaseGameSystem where T : BaseGameSystem
    // {
    //     // private static T _instance = null;
    //
    //     // public static T Instancee => _instance ??= MainArchitecture.Interface.GetSystem<T>();
    // }


    // /// <summary>
    // /// Mono系统类
    // /// </summary>
    // /// <typeparam name="T"></typeparam>
    // public abstract class BaseGameMonoSystem<T> : MonoBehaviour, ISystem where T : class, ISystem {
    //     public static T Instance => MainArchitecture.Interface.GetSystem<T>();
    //     private IArchitecture _architecture;
    //
    //     IArchitecture IBelongToArchitecture.GetArchitecture() {
    //         return _architecture;
    //     }
    //
    //     void ICanSetArchitecture.SetArchitecture(IArchitecture architecture) {
    //         _architecture = architecture;
    //     }
    //
    //     void ISystem.Init() {
    //         OnInit();
    //     }
    //
    //     protected abstract void OnInit();
    // }
}